﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NUnit.Framework;
using vudu.Logica.Clases;

namespace vudu.Pruebas
{
    [TestFixture]
    public class PruebaInicioSistema
    {
        /// prueba del metodo UsuarioRol
        [Test]
        public void PruebaConsultarUsuarioBD()
        {
            InicioSistema inicio = new InicioSistema();
            Rol rolActual = new Rol();
            rolActual = inicio.ConsultarUsuarioBD("magurno@prof.vudu.com", "12345");
            Assert.IsNotNull(rolActual);
            Assert.IsInstanceOf(typeof(Rol), rolActual);
            Assert.AreEqual(rolActual.Correo, "magurno@prof.vudu.com");
            Assert.AreEqual(rolActual.Password, "12345");
        }

        /// prueba del metodo ValidarDAtosIngresados
        [Test]
        public void PruebaValidarDatosIngresados()
        {
            InicioSistema inicio = new InicioSistema();
            bool aux = inicio.ValidarDatosIngresados("magurno@prof.vudu.com", "12345");
            bool aux2 = inicio.ValidarDatosIngresados("magurno@prof.vudu.com2", "12345");
            bool aux3 = inicio.ValidarDatosIngresados("magurnaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                "aaaaaaaaaaaaaaaaaao@prof.vudu.com", "12345");
            Assert.True(aux);
            Assert.False(aux2);
            Assert.False(aux3);
 
        }

        /// prueba del metodo EsCorreoCorrecto
        [Test]
        public void PruebaEsCorreoCorrecto()
        {
            InicioSistema inicio = new InicioSistema();
            bool aux = inicio.EsCorreoCorrecto("magurno@prof.vudu.com");
            bool aux2 = inicio.EsCorreoCorrecto("ma");
            bool aux3 = inicio.EsCorreoCorrecto("magurnaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                "aaaaaaaaaaaaaaaaaao@prof.vudu.com");
            Assert.True(aux);
            Assert.False(aux2);
            Assert.False(aux3);

        }

        /// prueba del metodo EsCorreoCorrecto
        [Test]
        public void PruebaEsPassCorrecto()
        {
            InicioSistema inicio = new InicioSistema();
            bool aux = inicio.EsPassCorrecto("12345");
            bool aux3 = inicio.EsPassCorrecto("magurnaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                "aaaaaaaaaaaaaaaaaao@prof.vudu.com");
            Assert.True(aux);
            Assert.False(aux3);

        }

        /// prueba del metodo TerminaEnDominio
        [Test]
        public void PruebaTerminaEnDominio()
        {
            InicioSistema inicio = new InicioSistema();
            bool aux = inicio.TerminaEnDominio("magurno@prof.vudu.com");
            bool aux2 = inicio.TerminaEnDominio("magurno@est.vudu.com");
            bool aux3 = inicio.TerminaEnDominio("magurno@esc.vudu.com");
            bool aux4 = inicio.TerminaEnDominio("magurno@univ.vudu.com");
            bool aux5 = inicio.TerminaEnDominio("magurno@prof.vudu.com3");
            Assert.True(aux);
            Assert.True(aux2);
            Assert.True(aux3);
            Assert.True(aux4);
            Assert.False(aux5);

        }

        /// prueba del metodo DefinirUsuario
        [Test]
        public void PruebaDefinirUsuario()
        {
            InicioSistema inicio = new InicioSistema();
            int opEst, opProf, opEsc, opUniv = 0;
            
            Rol rolEst = new Rol();
            Rol rolProf = new Rol();
            Rol rolEsc = new Rol();
            Rol rolUniv = new Rol();
            
            rolEst = inicio.ConsultarUsuarioBD("pedro@est.vudu.com", "12345");
            rolProf = inicio.ConsultarUsuarioBD("magurno@prof.vudu.com", "12345");
            rolEsc = inicio.ConsultarUsuarioBD("informatica@esc.vudu.com", "12345");
            rolUniv = inicio.ConsultarUsuarioBD("ucab@univ.vudu.com", "12345");

            opEst = inicio.DefinirUsuario(rolEst);
            opProf = inicio.DefinirUsuario(rolProf);
            opEsc = inicio.DefinirUsuario(rolEsc);
            opUniv = inicio.DefinirUsuario(rolUniv);

            Assert.AreEqual(opEst,1);
            Assert.AreEqual(opProf, 2);
            Assert.AreEqual(opEsc, 3);
            Assert.AreEqual(opUniv, 4);

        }

    }
}